home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 272_01 / ticker.doc < prev    next >
Text File  |  1987-07-15  |  2KB  |  48 lines

  1.  
  2.  
  3.  
  4.         NAME
  5.                 ticker -- timer interrupt service routine package
  6.  
  7.         SYNOPSIS
  8.                 void installtick(&counter);
  9.                 void removetick();
  10.                 unsigned int counter;     integer to decrement
  11.  
  12.  
  13.         DESCRIPTION
  14.         "ticker" is not actually a C function, but a routine which
  15.         is installed on interrupt 1CH.  At each interrupt (18.21
  16.         times per second) this routine decrements an integer (16 bits)
  17.         whose address was passed during installation.  The C program
  18.         can load and test this integer at any time to perform time-based
  19.         operations.  When the variable is decremented to zero, it
  20.         is not decremented any further; i.e., no underflow occurs.
  21.         Therefore, the integer is actually an unsigned integer with
  22.         a maximum count of 65535, or (65535/18.2) seconds.
  23.         installtick() installs the ticker on interrupt 1CH and
  24.         saves the address of the passed variable. removetick()
  25.         restores the interrupt 1CH vector to its original state.
  26.         Any other routines already installed on this vector are
  27.         executed after ticker, since the ticker chains to the
  28.         original vector after execution.
  29.  
  30.  
  31.         EXAMPLE
  32.  
  33.                  int  counter;
  34.  
  35.                  main() {
  36.                      installtick(&counter);
  37.                      counter = 18 * 10;  /* about 10 seconds */
  38.                      while(counter > 0); /* delay here */
  39.                      removetick();
  40.                      }
  41.  
  42.         CAVEAT
  43.              It is imperative to call removetick() BEFORE terminating
  44.              the program,  Otherwise, the system will crash!
  45.              See also ctlbrk() and criterr().
  46.  
  47.         This function is found in SMDLx.LIB for the Datalight Compiler
  48.